﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using IHISCETeim.BLL;
using System.Text;

namespace IHISCETeim.Web.Asmx
{
    public partial class AutoCompleteJs : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected string getagentlist()
        {
            DataTable dt = SBOController.GetAgentList();
            if (dt == null)
                return "";
           // string showtype = GetRequestValue<string>("showtype", "address");

            StringBuilder sb = new StringBuilder();
            foreach (DataRow dr in dt.Rows)
            {
                sb.AppendFormat("{{ name: '{0}', to: '{1}' }},", (string.IsNullOrEmpty(dr["AliasName"].ToString()) ? dr["CardName"] : dr["AliasName"]), (string.IsNullOrEmpty(dr["AliasName"].ToString()) ? dr["CardName"] : dr["AliasName"]));
                //Response.Write(string.Format("{0}|{1}\n", DR["itemcode"], DR["itemname"]));
            }
            return sb.ToString();
        }

        protected string getagentlist2()
        {
            DataTable dt = SBOController.GetAgentList();
            if (dt == null)
                return "";
            // string showtype = GetRequestValue<string>("showtype", "address");

            StringBuilder sb = new StringBuilder();
            sb.Append("[");
            foreach (DataRow dr in dt.Rows)
            {
                //sb.AppendFormat("{{ name: '{0}', to: '{1}' }},", (string.IsNullOrEmpty(dr["AliasName"].ToString()) ? dr["CardName"] : dr["AliasName"]), (string.IsNullOrEmpty(dr["AliasName"].ToString()) ? dr["CardName"] : dr["AliasName"]));
                //Response.Write(string.Format("{0}|{1}\n", DR["itemcode"], DR["itemname"]));
                sb.AppendFormat("\"{0}\",", string.IsNullOrEmpty(dr["AliasName"].ToString()) ? dr["CardName"] : dr["AliasName"]);
            }
            sb.Append("]");
            return sb.ToString();
        }
    }
}